//var xMove = keyboard_check(ord("D"))-keyboard_check(ord("A"));
//var yMove = keyboard_check(ord("S"))-keyboard_check(ord("W"));

//x += xMove * spd;
//y += yMove * spd;
//if (x >= stop_place0-4 && x <= stop_place0+4 && y >= stop_place1-4 && y <= stop_place1+4){speed = 0;}
//if !place_free(x-1*sign(hspeed),y+1*sign(vspeed)) {vspeed = 0;}
//if !place_free(x-1*sign(hspeed) + hspeed,y-1) {hspeed = 0;}
if(hspeed !=0 && vspeed != 0)
{
	// скилл вперёд выбор пути
	if (fw_spec > global.fw_special-1)
	{
	if (floor(abs(hspeed)) > 0) {targetx = x+sign(hspeed)*(200 + 10 *fw_level)} else {targetx = x}
	if (floor(abs(vspeed)) > 0) {targety = y+sign(vspeed)*(200 + 10 *fw_level)}	else {targety = y}
	}
	//скилл назад выбор пути
	if (sw_spec > global.sw_special-1 && instance_exists(o_Enemy))
	{
	if (floor(abs(hspeed)) > 0) {targetx = x+sign(o_Enemy.hspeed)*(100 + 10 *sw_level)} else {targetx = x}
	if (floor(abs(vspeed)) > 0) {targety = y+sign(o_Enemy.vspeed)*(100 + 10 *sw_level)}	else {targety = y}
	} 
	else if (sw_spec > global.sw_special-1)
	{
	if (floor(abs(hspeed)) > 0) {targetx = x-sign(hspeed)*(100 + 10 *sw_level)} else {targetx = x}
	if (floor(abs(vspeed)) > 0) {targety = y-sign(vspeed)*(100 + 10 *sw_level)}	else {targety = y}
	}
	// Скилл вперёд
	if (fw_spec > 0 )
	{
	move_towards_point(lerp(x,targetx,0.1),lerp(y,targety,0.1),fullspd*2)
	hp = oldhp
	if !place_free(x,y)  fw_spec++
	fw_spec += -1;
	
	}
	// Скилл назад
	if (sw_spec > 0 )
	{
	move_towards_point(lerp(x,targetx,0.1),lerp(y,targety,0.1),fullspd*3)
	hp = oldhp
	if !place_free(x,y)  sw_spec++
	sw_spec += -1;
	if (instance_exists(o_Enemy) && lock = 1 )	{
		Skill_shoting(point_direction(x,y,instance_nearest(x,y,o_Enemy).x,instance_nearest(x,y,o_Enemy).y), sw_level)
		lock = 0
		}
	} else {lock = 1}
	// Делаю бестелесным
	if (fw_spec > 0  || sw_spec>0)
	{
	mask_index = s_Empty;
	}else {mask_index = s_mainHero;}
	
} else {fw_spec = 0; sw_spec = 0;}
if (distance_to_object(o_level_block)<50){mask_index = s_mainHero;}